/*
 * Area de trabalho do usuario, onde podera fazer a comparação dos documentos;
 */
package br.inf.acesso.view.principal;

import br.inf.acesso.bancodedados.sqlserver.BDDocumentoEmp;
import br.inf.acesso.bancodedados.firebird.BDDocumentoTrib;
import br.inf.acesso.regrasdenegocios.geral.Documento;
import br.inf.acesso.validadores.CampoNumericoDocument;
import br.inf.acesso.validadores.Data;
import br.inf.acesso.validadores.Sobre;
import br.inf.acesso.validadores.Tabela;
import br.inf.acesso.view.geral.DocumentoItem;
import br.inf.acesso.view.tabelapesquisa.PesqEmpresa;
import java.awt.AWTKeyStroke;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.MaskFormatter;

/**
 * @author Douglas Giordano
 * @since 28/04/2013
 */
public class Principal extends javax.swing.JFrame {

    private DefaultTableModel modeloDocEmp;
    private DefaultTableModel modeloDocTrib;
    private DefaultTableModel modeloDocFalt;
    ArrayList<Documento> documentosQEmpEntradas;
    ArrayList<Documento> documentosQEmpSaidas;
    ArrayList<Documento> documentosQEmpOutrasEnt;
    ArrayList<Documento> documentosQEmpOutrasSai;
    ArrayList<Documento> documentosQTribEntradas;
    ArrayList<Documento> documentosQTribSaidas;
    ArrayList<Documento> documentosFaltando;

    /**
     * Creates new form Principal
     */
    public Principal() {
        documentosFaltando = new ArrayList<Documento>();

        initComponents();
        this.modeloDocEmp = (DefaultTableModel) areaDocumentosSQLServer.getModel();
        this.modeloDocTrib = (DefaultTableModel) areaDocumentosFirebird.getModel();
        this.modeloDocFalt = (DefaultTableModel) areaDocumentoFaltando.getModel();

        this.setResizable(false);
        this.setLocationRelativeTo(null);
        Set<AWTKeyStroke> forwardKeys = new HashSet<AWTKeyStroke>(this.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));
        forwardKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
        this.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        brInicialParar = new javax.swing.JButton();
        barraDeProgresso = new javax.swing.JProgressBar();
        jScrollPane4 = new javax.swing.JScrollPane();
        areaDocumentosSQLServer = new javax.swing.JTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        areaDocumentosFirebird = new javax.swing.JTable();
        jScrollPane6 = new javax.swing.JScrollPane();
        areaDocumentoFaltando = new javax.swing.JTable();
        txtDocumentosEmpresarial = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        iconAlertDtInvalida = new javax.swing.JLabel();
        txtFormatoData2 = new javax.swing.JLabel();
        campoEmpresa = new javax.swing.JTextField();
        txtFormatoData1 = new javax.swing.JLabel();
        txtEmpresa = new javax.swing.JLabel();
        txtDataFinal = new javax.swing.JLabel();
        txtDataInicial = new javax.swing.JLabel();
        campoDataFinal = new javax.swing.JFormattedTextField(createFormatter("##/##/####"));
        campoDataInicial = new javax.swing.JFormattedTextField(createFormatter("##/##/####"));
        btSelectEmpresa = new javax.swing.JButton();
        txtNomeEmpresa = new javax.swing.JLabel();
        btLogout = new javax.swing.JButton();
        btAbout = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Verificador De Documentos");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        brInicialParar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/inf/acesso/icons/iconComparar.png"))); // NOI18N
        brInicialParar.setText("Executar");
        brInicialParar.setToolTipText("Clique aqui para começar a comparar.");
        brInicialParar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        brInicialParar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                brInicialPararActionPerformed(evt);
            }
        });

        barraDeProgresso.setToolTipText("");

        areaDocumentosSQLServer.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Numero", "Valor", "Origem"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane4.setViewportView(areaDocumentosSQLServer);
        areaDocumentosSQLServer.getColumnModel().getColumn(1).setResizable(false);

        areaDocumentosFirebird.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Numero", "Valor", "Origem"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(areaDocumentosFirebird);
        areaDocumentosFirebird.getColumnModel().getColumn(1).setResizable(false);

        areaDocumentoFaltando.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Numero", "Valor", "Origem"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        areaDocumentoFaltando.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                areaDocumentoFaltandoMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(areaDocumentoFaltando);
        areaDocumentoFaltando.getColumnModel().getColumn(0).setResizable(false);
        areaDocumentoFaltando.getColumnModel().getColumn(1).setResizable(false);
        areaDocumentoFaltando.getColumnModel().getColumn(2).setResizable(false);
        areaDocumentoFaltando.getColumnModel().getColumn(3).setResizable(false);

        txtDocumentosEmpresarial.setText("Documentos Empresarial");

        jLabel1.setText("Documentos Questor Fiscal");

        jLabel2.setText("Documentos Ausentes");

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        iconAlertDtInvalida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/inf/acesso/icons/iconAlert.png"))); // NOI18N
        iconAlertDtInvalida.setToolTipText("Data Invalida");
        iconAlertDtInvalida.setVisible(false);

        txtFormatoData2.setText("(dd/mm/aaaa)");

        campoEmpresa.setDocument(new CampoNumericoDocument(true));
        campoEmpresa.setText("0");
        campoEmpresa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                campoEmpresaKeyReleased(evt);
            }
        });

        txtFormatoData1.setText("(dd/mm/aaaa)");

        txtEmpresa.setText("Empresa");

        txtDataFinal.setText("Data Final");

        txtDataInicial.setText("Data Inicial");

        btSelectEmpresa.setText("...");
        btSelectEmpresa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSelectEmpresaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtDataFinal)
                            .addComponent(txtDataInicial))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(campoDataFinal)
                            .addComponent(campoDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtFormatoData2)
                            .addComponent(txtFormatoData1))
                        .addGap(10, 10, 10)
                        .addComponent(iconAlertDtInvalida))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(txtEmpresa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(campoEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btSelectEmpresa)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNomeEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(iconAlertDtInvalida))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDataInicial)
                            .addComponent(campoDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtFormatoData1))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDataFinal)
                            .addComponent(campoDataFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtFormatoData2))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmpresa)
                    .addComponent(campoEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btSelectEmpresa)
                    .addComponent(txtNomeEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2))
        );

        btLogout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/inf/acesso/icons/iconLogoff.png"))); // NOI18N
        btLogout.setText("Logout");
        btLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLogoutActionPerformed(evt);
            }
        });

        btAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/inf/acesso/icons/iconAbout.png"))); // NOI18N
        btAbout.setText("Sobre");
        btAbout.setToolTipText("");
        btAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAboutActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(txtDocumentosEmpresarial)
                .addGap(146, 146, 146)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2)
                .addGap(101, 101, 101))
            .addGroup(layout.createSequentialGroup()
                .addComponent(brInicialParar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btLogout)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btAbout))
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(barraDeProgresso, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btAbout, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(brInicialParar)
                        .addComponent(btLogout)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(barraDeProgresso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDocumentosEmpresarial)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void brInicialPararActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_brInicialPararActionPerformed
        barraDeProgresso.setValue(0);
        if (Data.isDateValid(campoDataInicial.getText())) {
            if (Data.isDateValid(campoDataFinal.getText())) {
                iconAlertDtInvalida.setVisible(false);

                limparInfo();
                pesquisaDocQEmp();
                pesquisaDocQTrib();
                Documento.listaDocumentos(documentosQEmpEntradas, modeloDocEmp);
                Documento.listaDocumentos(documentosQEmpSaidas, modeloDocEmp);
                Documento.listaDocumentos(documentosQEmpOutrasEnt, modeloDocEmp);
                Documento.listaDocumentos(documentosQEmpOutrasSai, modeloDocEmp);
                barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
                Documento.listaDocumentos(documentosQTribEntradas, modeloDocTrib);
                Documento.listaDocumentos(documentosQTribSaidas, modeloDocTrib);
                barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
                comparaDoc();
                Documento.listaDocumentosMd2(documentosFaltando, modeloDocFalt);
                barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            } else {
                iconAlertDtInvalida.setVisible(true);
            }
        } else {
            iconAlertDtInvalida.setVisible(true);
        }
    }//GEN-LAST:event_brInicialPararActionPerformed

    private void btLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLogoutActionPerformed
        dispose();
        new Login().setVisible(true);
    }//GEN-LAST:event_btLogoutActionPerformed

    private void btSelectEmpresaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSelectEmpresaActionPerformed
        new PesqEmpresa(this, true, campoEmpresa, txtNomeEmpresa).setVisible(true);
    }//GEN-LAST:event_btSelectEmpresaActionPerformed

    private void areaDocumentoFaltandoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_areaDocumentoFaltandoMouseClicked
        if (evt.getClickCount() > 1) {
            int codigo = areaDocumentoFaltando.getSelectedRow();
            String numeroDoc = areaDocumentoFaltando.getValueAt(codigo, 0) + "";
            String origem = areaDocumentoFaltando.getValueAt(codigo, 3) + "";
            new DocumentoItem(this, true, numeroDoc, origem).setVisible(true);
        }
    }//GEN-LAST:event_areaDocumentoFaltandoMouseClicked

    private void btAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAboutActionPerformed
        new Sobre(this, true).setVisible(true);
    }//GEN-LAST:event_btAboutActionPerformed

    private void campoEmpresaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoEmpresaKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_F5) {
            new PesqEmpresa(this, true, campoEmpresa, txtNomeEmpresa).setVisible(true);
        }
    }//GEN-LAST:event_campoEmpresaKeyReleased


    /**
     * Cria uma mascara para formatar o campo.
     *
     * @param s
     * @return formatação
     */
    protected MaskFormatter createFormatter(String s) {
        MaskFormatter formatter = null;
        try {
            formatter = new MaskFormatter(s);
        } catch (java.text.ParseException exc) {
            System.out.println("formatador é ruim:" + exc.getMessage());
            System.exit(-1);
        }
        return formatter;
    }

    private void pesquisaDocQEmp() {
        BDDocumentoEmp documentosEmp = new BDDocumentoEmp(campoDataInicial.getText(), campoDataFinal.getText());
        try {
            documentosQEmpEntradas = documentosEmp.docNFEntradas();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosQEmpSaidas = documentosEmp.docNFSaidas();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosQEmpOutrasEnt = documentosEmp.docNFOutrasEnt();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosQEmpOutrasSai = documentosEmp.docNFOutrasSai();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosEmp.desconectar();
        } catch (SQLException erro) {
            JOptionPane.showMessageDialog(null, erro);
        }

    }

    private void pesquisaDocQTrib() {
        BDDocumentoTrib documentosTrib = new BDDocumentoTrib(campoDataInicial.getText(), campoDataFinal.getText(), campoEmpresa.getText());
        try {
            documentosQTribEntradas = documentosTrib.docNFEntradas();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosQTribSaidas = documentosTrib.docNfSaidas();
            barraDeProgresso.setValue(barraDeProgresso.getValue() + 10);
            documentosTrib.desconectar();
        } catch (SQLException erro) {
            JOptionPane.showMessageDialog(null, erro);
        }

    }

    public void limparInfo() {
        Tabela.limparTabela(modeloDocEmp);
        Tabela.limparTabela(modeloDocTrib);
        Tabela.limparTabela(modeloDocFalt);
        if (documentosFaltando != null) {
            documentosFaltando.removeAll(documentosFaltando);
        }
    }

    public void comparaDoc() {
        documentosFaltando.addAll(Documento.comparaDocumentos(documentosQEmpEntradas, documentosQTribEntradas));
        barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
        documentosFaltando.addAll(Documento.comparaDocumentos(documentosQEmpSaidas, documentosQTribSaidas));
        barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
        documentosFaltando.addAll(Documento.comparaDocumentos(documentosQEmpOutrasEnt, documentosQTribEntradas));
        barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
        documentosFaltando.addAll(Documento.comparaDocumentos(documentosQEmpOutrasSai, documentosQTribSaidas));
        barraDeProgresso.setValue(barraDeProgresso.getValue() + 5);
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable areaDocumentoFaltando;
    private javax.swing.JTable areaDocumentosFirebird;
    private javax.swing.JTable areaDocumentosSQLServer;
    private javax.swing.JProgressBar barraDeProgresso;
    private javax.swing.JButton brInicialParar;
    private javax.swing.JButton btAbout;
    private javax.swing.JButton btLogout;
    private javax.swing.JButton btSelectEmpresa;
    private javax.swing.JFormattedTextField campoDataFinal;
    private javax.swing.JFormattedTextField campoDataInicial;
    private javax.swing.JTextField campoEmpresa;
    private javax.swing.JLabel iconAlertDtInvalida;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JLabel txtDataFinal;
    private javax.swing.JLabel txtDataInicial;
    private javax.swing.JLabel txtDocumentosEmpresarial;
    private javax.swing.JLabel txtEmpresa;
    private javax.swing.JLabel txtFormatoData1;
    private javax.swing.JLabel txtFormatoData2;
    private javax.swing.JLabel txtNomeEmpresa;
    // End of variables declaration//GEN-END:variables
}
